﻿using System;
class MinMaxNumber
{
    static void Main()
    {
        int ammount;
        int number;
        int minnumber = 0;
        int maxnumber = 0;
        Console.Write("Please enter ammount: ");
        while (true)
        {
            try
            {
                ammount = int.Parse(Console.ReadLine());
                break;
            }
            catch (Exception)
            {
                Console.Write("Please re-enter ammount:");
            }
        }
        Console.WriteLine("Now please enter numbers: ");
        for (int i = 0; i < ammount; i++)
        {
            while (true)
            {
                try
                {
                    number = int.Parse(Console.ReadLine());
                    break;
                }
                catch (Exception)
                {
                    Console.Write("Please re-enter number:");
                }
            }
            if (i == 0)
            {
                minnumber = number;
                maxnumber = number;
            }
            else
            {
                if (number > maxnumber)
                {
                    maxnumber = number;
                }
                else
                {
                    if (number < minnumber)
                    {
                        minnumber = number;
                    }
                }
            }
        }
        Console.WriteLine("The minimal value is: {0}", minnumber);
        Console.WriteLine("The maximal value is: {0}", maxnumber);
        Console.ReadLine();
    }
}

